package com.yonyougov.devops.cruxcisupport.versioninfo;

import com.yonyougov.devops.cruxcisupport.versioninfo.dto.VersionInfoPageDto;
import com.yonyougov.devops.cruxcisupport.versioninfo.vo.VersionInfoPageVo;
import com.yonyougov.devops.fwc.core.dao.impl.BaseDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * t_version_info数据层实现
 */
@Repository
public class VersionInfoDaoImpl extends BaseDaoImpl<VersionInfoEntity, BigInteger> implements VersionInfoDao {
    //<!--用户自定义代码开始-->
    private final SqlSessionTemplate sqlSessionTemplate;

    public VersionInfoDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    @Override
    public int countBy(VersionInfoPageDto versionInfoPageDto) {
        String statement = VersionInfoEntity.class.getName() + "Mapper.countByApp";
        return sqlSessionTemplate.selectOne(statement, versionInfoPageDto);
    }

    @Override
    public List<VersionInfoPageVo> findPageBy(VersionInfoPageDto versionInfoPageDto) {
        String statement = VersionInfoEntity.class.getName() + "Mapper.findAllJoinByApp";
        return sqlSessionTemplate.selectList(statement, versionInfoPageDto);
    }

    @Override
    public List<VersionInfoPageVo> findNotRelation() {
        String statement = VersionInfoEntity.class.getName() + "Mapper.findNotRelation";
        return sqlSessionTemplate.selectList(statement);
    }

    //<!--用户自定义代码结束-->
}
